<template>
	<el-tabs class="survey_index_wrapper" v-model="activeName">
		<el-tab-pane label="题目管理" name="subject"><subject-manage></subject-manage></el-tab-pane>
		<el-tab-pane label="问卷管理" name="survey">
			<survey-result v-if="!!isResult"></survey-result>
			<survey-manage v-else></survey-manage>
		</el-tab-pane>
		<el-tab-pane label="问卷统计" name="stat"><statistics></statistics></el-tab-pane>
	</el-tabs>
</template>

<script>
import surveyManage from './survey';
import subjectManage from './subject';
import surveyResult from './result';
import statistics from './statistics';
export default {
	components: { surveyManage, subjectManage, surveyResult, statistics },
	data() {
		return {
			isResult: false,
			activeName: 'stat'
		};
	},
	computed: {
		questionId() {
			return this.$route.query.id;
		},
		resultPage() {
			return !this.$route.query.result;
		}
	},
	watch: {
		resultPage: {
			handler(val) {
				this.isResult = !val;
			},
			immediate: true
		},
		activeName(val) {
			if (this.resultPage) return false;
			this.$router.replace({
				path: '/admin/column/survey'
			});
		}
	}
};
</script>

<style scoped></style>
